package cn.hadron.aa.action.admin;
import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.hadron.aa.entity.Article;
import cn.hadron.aa.service.ArticleService;
import cn.hadron.aa.util.Pager;

import com.opensymphony.xwork2.ActionSupport;
@Controller
@Scope("prototype") 
@ParentPackage("admin")
@Namespace("/admin")
public class ArticleList extends ActionSupport {
	private int id;   //页号
	private int cid;  //栏目号
	private Pager<Article> pager ;
	@Resource(name="articleService")
	private ArticleService as;
	@Action(value="list", results={@Result(name="success",location="/admin/list.jsp")})
	public String page() throws Exception {
		if(cid>0){
			pager=as.getPager(cid,id, 5);
			pager.setUrl("list?cid="+cid);
		}else{
			pager=as.getPager(id, 5);
			pager.setUrl("list");
		}
		return SUCCESS;
	}	
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}

	public Pager<Article> getPager() {
		return pager;
	}
	public void setPager(Pager<Article> pager) {
		this.pager = pager;
	}
	
	public ArticleService getAs() {
		return as;
	}
	public void setAs(ArticleService as) {
		this.as = as;
	}

	public int getCid() {
		return cid;
	}

	public void setCid(int cid) {
		this.cid = cid;
	}
}
